<?php
/**
 * Created by PhpStorm.
 * User: j28981
 * Date: 2015/9/1
 * Time: 13:57
 */
class userModel extends dbo{
    protected  $table='user';
    public function getALL($field,$value){
        $where=1;
        if($value!=''){
            $where.=" and $field='$value'";
        }
        $sql="select * from {$this->getTable()} where $where order by user_id desc ";

        return $this->queryAll($sql);
    }
    public function addUser($name,$pwd,$role){
        $pwd = md5($pwd);
        $sql="insert into {$this->getTable()} values (null,'$name','$pwd','$role')";
        return $this->Insert($sql);
    }
    public static function updateUser($name,$pwd,$role,$id){
        $sql = "update #__user set user_name='$name',user_password ='$pwd',user_role='$role' where user_id='$id'";
        return Db::Update($sql);
    }
}